From 10c7fd8c9ba9814c7e44aa9581f700c441e19920 Mon Sep 17 00:00:00 2001 From: "kaf24@freefall.cl.cam.ac.uk" Date: Sat, 25 Sep 2004 09:23:15 +0000 Subject: [PATCH] bitkeeper revision 1.1159.1.182 (41553903CsSyg7DOBEoizwc3e0V0OA) Move Xen evetchn chrdev to 10,201 so we don't conflict with tun. --- linux-2.6.8.1-xen-sparse/include/asm-xen/evtchn.h | 4 ++-- tools/python/xen/lowlevel/xu/xu.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/linux-2.6.8.1-xen-sparse/include/asm-xen/evtchn.h b/linux-2.6.8.1-xen-sparse/include/asm-xen/evtchn.h index d4c43ee91d..597dce83cd 100644 --- a/linux-2.6.8.1-xen-sparse/include/asm-xen/evtchn.h +++ b/linux-2.6.8.1-xen-sparse/include/asm-xen/evtchn.h @@ -72,8 +72,8 @@ static inline void notify_via_evtchn(int port) * CHARACTER-DEVICE DEFINITIONS */ -/* /dev/xen/evtchn resides at device number major=10, minor=200 */ -#define EVTCHN_MINOR 200 +/* /dev/xen/evtchn resides at device number major=10, minor=201 */ +#define EVTCHN_MINOR 201 /* /dev/xen/evtchn ioctls: */ /* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */ diff --git a/tools/python/xen/lowlevel/xu/xu.c b/tools/python/xen/lowlevel/xu/xu.c index 813f357464..9267d65967 100644 --- a/tools/python/xen/lowlevel/xu/xu.c +++ b/tools/python/xen/lowlevel/xu/xu.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,7 @@ /* NB. The following should be kept in sync with the kernel's evtchn driver. */ #define EVTCHN_DEV_NAME "/dev/xen/evtchn" #define EVTCHN_DEV_MAJOR 10 -#define EVTCHN_DEV_MINOR 200 +#define EVTCHN_DEV_MINOR 201 /* /dev/xen/evtchn ioctls: */ /* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */ #define EVTCHN_RESET _IO('E', 1) @@ -192,12 +193,19 @@ staticforward PyTypeObject xu_notifier_type; static PyObject *xu_notifier_new(PyObject *self, PyObject *args) { xu_notifier_object *xun; + struct stat st; if ( !PyArg_ParseTuple(args, "") ) return NULL; xun = PyObject_New(xu_notifier_object, &xu_notifier_type); + /* Make sure any existing device file links to correct device. */ + if ( (lstat(EVTCHN_DEV_NAME, &st) != 0) || + !S_ISCHR(st.st_mode) || + (st.st_rdev != makedev(EVTCHN_DEV_MAJOR, EVTCHN_DEV_MINOR)) ) + (void)unlink(EVTCHN_DEV_NAME); + reopen: xun->evtchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR); if ( xun->evtchn_fd == -1 ) @@ -205,7 +213,7 @@ static PyObject *xu_notifier_new(PyObject *self, PyObject *args) if ( (errno == ENOENT) && ((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) && (mknod(EVTCHN_DEV_NAME, S_IFCHR|0600, - (EVTCHN_DEV_MAJOR << 8) | EVTCHN_DEV_MINOR) == 0) ) + makedev(EVTCHN_DEV_MAJOR,EVTCHN_DEV_MINOR)) == 0) ) goto reopen; PyObject_Del((PyObject *)xun); return PyErr_SetFromErrno(PyExc_IOError); -- 2.30.2